home *** CD-ROM | disk | FTP | other *** search
/ 10,000 Great Games / 10,000 Great Games.iso / Product / 66 / data1.cab / Source_Files / Src / Dinput.cpp < prev    next >
C/C++ Source or Header  |  2000-01-16  |  713b  |  32 lines

  1. #include "stdafx.h"
  2.  
  3. LPDIRECTINPUT DI = 0;
  4.  
  5. void init_directinput()
  6. {
  7.     if (FAILED(DirectInputCreate(theApp.m_hInstance, DIRECTINPUT_VERSION, &DI, 0)))
  8.         error("Unable to create DirectInput interface\n\n"
  9.               "Did you install DirectX 6.0 or higher?");
  10. }
  11.  
  12. void deinit_directinput()
  13. {
  14.     safe_release(&DI);
  15. }
  16.  
  17. LPDIRECTINPUTDEVICE2 create_input_device(GUID guid)
  18. {
  19.     LPDIRECTINPUTDEVICE id1;
  20.     LPDIRECTINPUTDEVICE2 id2;
  21.  
  22.     if (FAILED(DI->CreateDevice(guid, &id1, 0)))
  23.         error("Unable to get DirectInputDevice interface");
  24.  
  25.     if (FAILED(id1->QueryInterface(IID_IDirectInputDevice2, (LPVOID *)&id2)))
  26.         error("Unable to get DirectInputDevice2 interface");
  27.  
  28.     id1->Release();
  29.  
  30.     return id2;
  31. }
  32.